package com.example.shop.modules.manage.controller;


import com.example.shop.modules.manage.service.IGoodsSpecAdminService;
import com.example.shop.persistence.entity.GoodsSpec;
import com.example.shop.utils.JSONResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import static com.example.shop.utils.JSONResult.renderSuccess;

/**
 * <p>
 * 商品规格分类名称表 前端控制器
 * </p>
 *
 * @author jason
 * @since 2020-06-05
 */
@Api(tags = "后台接口商品规格分类名称表")
@RestController
@RequestMapping("/manage/goodsSpec")
public class GoodsSpecAdminController {

    @Autowired
    private IGoodsSpecAdminService goodsSpecService;

    @GetMapping
    @ApiOperation(value = "查询商品规格分类名称",notes = "不分页，不分级")
    public JSONResult getGoodsSpecList(){
        return renderSuccess(goodsSpecService.list());
    }

    @PostMapping
    @ApiOperation(value = "新增或更新",notes = "新增或更新商品规格分类名称.有ID就是更新")
    public JSONResult updateGoodsSpec(GoodsSpec goodsSpec){
        return renderSuccess(goodsSpecService.saveOrUpdate(goodsSpec));
    }

    @DeleteMapping
    @ApiOperation(value = "删除", notes = "传单个ID")
    public JSONResult deleteGoodsSpec(Integer id){
        return renderSuccess(goodsSpecService.removeById(id));
    }

}

